package com.yaorange.web.controller.nongit;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yaorange.common.annotation.Log;
import com.yaorange.common.core.controller.BaseController;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.enums.BusinessType;
import com.yaorange.nongit.domain.NjtAdminPrinterseq;
import com.yaorange.nongit.service.INjtAdminPrinterseqService;
import com.yaorange.common.utils.poi.ExcelUtil;
import com.yaorange.common.core.page.TableDataInfo;

/**
 * 打印机序列号管理Controller
 * 
 * @author lzh
 * @date 2025-02-28
 */
@RestController
@RequestMapping("/nongit/printerseq")
public class NjtAdminPrinterseqController extends BaseController
{
    @Autowired
    private INjtAdminPrinterseqService njtAdminPrinterseqService;

    /**
     * 查询打印机序列号管理列表
     */
    @PreAuthorize("@ss.hasPermi('nongit:printerseq:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtAdminPrinterseq njtAdminPrinterseq)
    {
        startPage();
        List<NjtAdminPrinterseq> list = njtAdminPrinterseqService.selectNjtAdminPrinterseqList(njtAdminPrinterseq);
        return getDataTable(list);
    }

    /**
     * 导出打印机序列号管理列表
     */
    @PreAuthorize("@ss.hasPermi('nongit:printerseq:export')")
    @Log(title = "打印机序列号管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtAdminPrinterseq njtAdminPrinterseq)
    {
        List<NjtAdminPrinterseq> list = njtAdminPrinterseqService.selectNjtAdminPrinterseqList(njtAdminPrinterseq);
        ExcelUtil<NjtAdminPrinterseq> util = new ExcelUtil<NjtAdminPrinterseq>(NjtAdminPrinterseq.class);
        util.exportExcel(response, list, "打印机序列号管理数据");
    }

    /**
     * 获取打印机序列号管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongit:printerseq:query')")
    @GetMapping(value = "/{printerId}")
    public AjaxResult getInfo(@PathVariable("printerId") Long printerId)
    {
        return success(njtAdminPrinterseqService.selectNjtAdminPrinterseqByPrinterId(printerId));
    }

    /**
     * 新增打印机序列号管理
     */
    @PreAuthorize("@ss.hasPermi('nongit:printerseq:add')")
    @Log(title = "打印机序列号管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NjtAdminPrinterseq njtAdminPrinterseq)
    {
        return toAjax(njtAdminPrinterseqService.insertNjtAdminPrinterseq(njtAdminPrinterseq));
    }

    /**
     * 修改打印机序列号管理
     */
    @PreAuthorize("@ss.hasPermi('nongit:printerseq:edit')")
    @Log(title = "打印机序列号管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NjtAdminPrinterseq njtAdminPrinterseq)
    {
        return toAjax(njtAdminPrinterseqService.updateNjtAdminPrinterseq(njtAdminPrinterseq));
    }

    /**
     * 删除打印机序列号管理
     */
    @PreAuthorize("@ss.hasPermi('nongit:printerseq:remove')")
    @Log(title = "打印机序列号管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{printerIds}")
    public AjaxResult remove(@PathVariable Long[] printerIds)
    {
        return toAjax(njtAdminPrinterseqService.deleteNjtAdminPrinterseqByPrinterIds(printerIds));
    }
}
